{% extends "tasks/base.html" %}

{% load i18n %}
{% load account_tags %}
{% load tasks_tags %}
{% load shorttimesince_tag %}
{% load humanize %}
{% load group_tags %}

{% block head_title %}Today's tasks for {% user_display other_user %}{% endblock %}

{% block body %}
    <h1>Today's tasks for <a href="{% url profile_detail other_user %}">{% user_display other_user %}</a></h1>
    
    {% if planned_task_exists %}
        
        <table class="task_list">
            {% cycle odd even as rowcolors %}
            <tr>
                <th>Summary</th>
                <th>Worked-on/Done</th>
            </tr>

            {% if first_tasks %}
              {% with "first" as section %}
              {% with first_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date == today %}task_closed{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl worked_on group username=other_user id=task.id %}">Done</a>
                                      <a href="{% groupurl close group username=other_user id=task.id %}">Done for good</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No first task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}

            {% if before_tasks %}
              {% with "before" as section %}
              {% with before_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date == today %}task_closed{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl worked_on group username=other_user id=task.id %}">Done</a>
                                      <a href="{% groupurl close group username=other_user id=task.id %}">Done for good</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No before task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}
            
            {% if normal_tasks %}
              {% with "normal" as section %}
              {% with normal_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date == today %}task_closed{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl worked_on group username=other_user id=task.id %}">Done</a>
                                      <a href="{% groupurl close group username=other_user id=task.id %}">Done for good</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No normal task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}
            
            {% if after_tasks %}
              {% with "after" as section %}
              {% with after_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date == today %}task_closed{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl task_detail group id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl worked_on group username=other_user id=task.id %}">Done</a>
                                      <a href="{% groupurl close group username=other_user id=task.id %}">Done for good</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No after task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}
            
        </table>
        
    {% else %}
        {% trans "You have no planned tasks for today right now." %}
    {% endif %}
    
{% endblock %}
